from selenium.webdriver.common.by import By
from pykeyboard import PyKeyboard # 在PyUserInput中，需要额外引入pypiwin32
from time import sleep

class Charge():

    def __init__(self, driver):
        self.driver = driver

    def charge(self):
        # 资金管理/余额充值
        self.driver.find_element(By.XPATH, '/html/body/div/div/div[2]/div/div/div[2]/div[1]/div[1]/div[2]/ul/li[1]/a').click()
        # 输入充值金额
        self.driver.find_element(By.XPATH, '/html/body/div[3]/div[2]/div[1]/div[2]/div/input').send_keys('0.00')
        # 选择支付方式
        self.driver.find_element(By.XPATH, '/html/body/div[3]/div[2]/div[3]/div[1]/ul/li[1]').click()
        sleep(2)

    def payword(self):
        action = self.driver.find_element(By.XPATH, '/html/body/div[3]/div[2]/div[3]/div[2]/form/div[13]/div/ul/li[1]')
        action.click()
        key = PyKeyboard()
        key.tap_key('6')
        key.tap_key('1')
        key.tap_key('1')
        key.tap_key('1')

